package com.glory.brepda.adapter;

import android.os.Bundle;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.glory.brepda.R;
import com.glory.brepda.activity.mfg.BomInfoCheckActivity;
import com.glory.brepda.activity.mfg.GroupEqpInfoCheckActivity;
import com.glory.brepda.entity.BomInfoEntity;
import com.glory.brepda.entity.EqpStatusEntity;
import com.pda.platform.ui.ui_pdaplatform.utils_public.FreeApi_LogUtils;
import com.pda.platform.ui.ui_pdaplatform.utils_public.FreeApi_Utils;

import java.util.List;

public class GroupEqpListAdapter extends BaseQuickAdapter<EqpStatusEntity.ResultBean, BaseViewHolder> {
    private boolean mStatus = true;

    public GroupEqpListAdapter(@Nullable List<EqpStatusEntity.ResultBean> data, boolean status) {
        super(R.layout.item_group_eqp_adapter,data);
        this.mStatus = status;
    }

    @Override
    protected void convert(BaseViewHolder helper, EqpStatusEntity.ResultBean item) {
        helper.setText(R.id.tvEqpId,item.getEPQID());
        if(item.getSTATU().equals("IDLE")){
            helper.setText(R.id.tvState,"待机");
        }else if (item.getSTATU().equals("RUN") || item.getSTATU().equals("RUN2")){
            helper.setText(R.id.tvState,"运行中");
        }else if(item.getSTATU().equals("PM")){
            helper.setText(R.id.tvState,"保养中");
        }

        if (item.getHOLDSTATU().equals("On")){
            helper.setText(R.id.tvHoldState,"暂扣");
        }else{
            helper.setText(R.id.tvHoldState,"未暂扣");
        }


        helper.getView(R.id.llGroupEqpLayout).setOnClickListener(view -> {
            //判断是否可点击
            if (mStatus)
                return;
            Bundle bundle= new Bundle();
            bundle.putSerializable("GROUPEQP",item);


            FreeApi_LogUtils.saveErrorMessages(item.toString(),"GROUPEQP");

            FreeApi_Utils.skipWithExtraIntent("header",bundle,mContext, GroupEqpInfoCheckActivity.class);

        });
    }
}
